from fastapi import APIRouter, Body

from application.mcp.block_type_mcp_tool import ScheduleBlockSchema, block_type_tool
from application.mcp.excel_mcp_tool import excel_to_json_array_tool
from application.mcp.interface_implementer_mcp_tool import InterfaceInfoSchema, \
    interface_implementer_tool
from application.mcp.value_constants_mcp_tool import value_constants_tool

router = APIRouter(
    tags=['mcp'],
    prefix="/mcp",
)


# 使用operation_id作为MCP工具名称

@router.post(
    '/excel_to_json_array',
    operation_id='excel_to_json_array',
    summary='excel转JSON数组工具',
    description='将excel表格数据转换为JSON二维数组',
    response_model=list[list],
)
def excel_tool_endpoint(
        excel_file: str = Body(..., embed=True, description='excel文件绝对路径路径')
):
    return excel_to_json_array_tool(excel_file)


@router.post(
    '/interface_implementer',
    operation_id='interface_implementer',
    summary='接口信息工具',
    description='根据提供的接口名称返回对应接口定义信息',
    response_model=list[InterfaceInfoSchema],
)
def interface_implementer(
        interface_name_list: list[str] = Body(..., embed=True, description="接口名称列表")
):
    return interface_implementer_tool(interface_name_list)


@router.post(
    '/block_type',
    operation_id='block_type',
    summary='排期block工具',
    description='根据排期类型确定所需使用的对应block方法',
    response_model=ScheduleBlockSchema,
)
def block_type_tool_endpoint(
        schedule_type_list: list[str] = Body(..., embed=True, description='支持的排期类型')
):
    return block_type_tool(schedule_type_list)


@router.post(
    '/value_constants',
    operation_id='value_constants',
    summary='value.go工具',
    description='将用户提供的常量转化为活动value.go文件中的常量',
    response_model=str,
)
def value_constants_endpoint(
        activity_template_type: str = Body(..., description='活动模板类型'),
        activity_version: str = Body(..., description='活动版本'),
        activity_name: str = Body(..., description='活动名称'),
):
    return value_constants_tool(activity_template_type, activity_version, activity_name)

# @router.post(
#     '/family_bucket_config_item',
#     operation_id='family_bucket_config_item',
#     summary='全家桶工具',
#     description='传入配置项JSON二维数组，确认是否可复用全家桶配置项',
#     response_model=str,
# )
# def family_bucket(
#         config_item: list[list] = Body(..., embed=True, description='配置项内容')
# ):
#     return family_bucket_config_item(config_item)
